package com.hp.btc.util;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;

public class JsonDateDeserialize extends JsonDeserializer<Date>{
	
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");

	@Override
	public Date deserialize(JsonParser parse, DeserializationContext context)
			throws IOException, JsonProcessingException {
		String date = parse.getText();
		try {
			Date current = dateFormat.parse(date);
			
            return current;
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
	}
	
	

}
